package auction.bbs.dao;

import java.io.IOException;





import java.sql.SQLException;
import java.util.List;

import auction.util.SqlMapLocator;
import auction.bbs.dto.BbsDTO;



public class BbsDao {
	private static BbsDao singleton;
	
	public static BbsDao getinstance() throws IOException{
		if (singleton == null) {
			singleton = new BbsDao();
		}
		return singleton;
	}
	
	private BbsDao(){
		
	}

	
	
	public void insert(BbsDTO bbsDTO) throws SQLException{
		SqlMapLocator.getMapper().insert("bbs.insertData",bbsDTO);
		
	}
	
	
	public int getCount()throws SQLException{
		return (int) SqlMapLocator.getMapper().queryForObject("bbs.getCount");
	}
	
	
	@SuppressWarnings("unchecked")
	public List<BbsDTO> getList() throws SQLException{
		return (List<BbsDTO>) SqlMapLocator.getMapper().queryForList("bbs.getList");
	}
	
	
	@SuppressWarnings("unchecked")
	public List<BbsDTO> getListTEST(int currentPage) throws SQLException{
		return (List<BbsDTO>) SqlMapLocator.getMapper().queryForList("bbs.getListtest",currentPage);
	}
	
	
	public BbsDTO getData(int seq) throws SQLException{
		return (BbsDTO) SqlMapLocator.getMapper().queryForObject("bbs.getData",seq);
	}
}
